import BasePageCtrl, { AnimType } from "./BasePageCtrl";
import LoadingPage from "./LoadingPage";
import NativeUtils from "./NativeUtils";
const { ccclass, property, menu } = cc._decorator;

@ccclass
@menu("UI/pages/LoadingPageCtrl")
export default class LoadingPageCtrl extends BasePageCtrl {
    @property(LoadingPage)
    ui = null;

    onLoad() {
        super.onUILoad();
        this._animType = AnimType.FADE;
        this._animTime = 1.5;
        this._touchControl = false;
        this._hasPeneLock = true;
        this._hasBlack = true;
        this._hasTouchLock = false;
        this._hasBlackTouch = false;
        super.onLoad();
        this.addButtonListen();
    }

    start() {}

    onUILoad() {
        this.ui = this.node.addComponent(LoadingPage);
        
        NativeUtils.gameLoadSuccess();
    }

    addButtonListen() {}

    _init(e?) {
        if (e && e.data) {
            const callback = e.data.callback;
            this.unscheduleAllCallbacks();
            this.scheduleOnce(() => {
                if (callback) {
                    callback();
                    this.hide();
                }
            }, 0.5);
        }
    }

    clickClose() {
        this.hide();
    }

    static prefabUrl = "LoadingPage";
    static className = "LoadingPageCtrl";
}
